package com.xc.voicechat.controller;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xc.voicechat.config.VoiceChatConfig;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.http.ResponseEntity;

@RestController
@RequestMapping("/api/chat")
public class ChatController {

  @Resource
  private VoiceChatConfig voiceChatConfig;


  // 新增安全码校验接口
  @GetMapping("/checkSecurity")
  public ResponseEntity<String> checkSecurity(@RequestParam("code") String code) {
    boolean valid = voiceChatConfig.auth(code);
    return ResponseEntity.ok().body(valid ? "ok" : "invalid");
  }
 }